﻿using System;
using System.Collections.Generic;
using System.Globalization;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows;
using System.Windows.Data;

namespace DryWCS.App.Converter
{
    public class RoleConverter : IValueConverter
    {
        public object Convert(object value, Type targetType, object parameter, CultureInfo culture)
        {
            string ret=null;
            if (value != null)
            {
                string str = value.ToString();
                switch(str)
                {
                    case "1":
                        ret = "管理员";
                        break;
                    case "2":
                        ret = "一般用户";
                        break;
                    default:
                        ret = "未知用户";
                        break;
                }
               
            }
            return ret;
        }

        public object ConvertBack(object value, Type targetType, object parameter, CultureInfo culture)
        {
            int ret = 2;
            if (value != null)
            {
                string str = value.ToString();
                switch (str)
                {
                    case "管理员":
                        ret = 1;
                        break;
                    case "一般用户":
                        ret = 2;
                        break;
                    default:
                        ret = 2;
                        break;
                }

            }
            return ret;
        }
    }
}
